using System;
using dbvc.context.Version;
using dbvc.data;
using dbvc.Queries;
using NUnit.Framework;

namespace tdd.dbvc
{
    public partial class tests
    {
        [Test]
        public void add_version()
        {
            root_login();

            add_projects();

            var prj = GenericQuery<db_project>.GetAll()[0];

            new CreateVersion(security.Principal, prj, new db_version() { name = "X1", on_date = DateTime.Today.AddDays(1) }).Execute();
            new CreateVersion(security.Principal, prj, new db_version() { name = "X2", on_date = DateTime.Today.AddDays(2) }).Execute();
            new CreateVersion(security.Principal, prj, new db_version() { name = "X3", on_date = DateTime.Today.AddDays(3) }).Execute();

            Assert.AreEqual(3, GenericQuery<db_version>.Count());
        }

        [Test]
        public void del_version()
        {
            root_login();

            new DeleteVersion(security.Principal, GenericQuery<db_version>.GetAll()).Execute();

            Assert.AreEqual(GenericQuery<db_version>.Count(), 0);
        }
    }
}